/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dominio;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Huliane
 * <br>
 * Classe MateriaPrima. Contém 4 atributos: id (identifica-o no BD), nome (nome da materiaPrima), <br>preco (preço da materiaPrima)
 * e codigo (código da materiaPrima).
 */
@Entity
@Table(name = "MATERIAPRIMA")
@NamedQueries({
    @NamedQuery(name = "MateriaPrima.findAll", query = "SELECT m FROM MateriaPrima m"),
    @NamedQuery(name = "MateriaPrima.findById", query = "SELECT m FROM MateriaPrima m WHERE m.id = :id"),
    @NamedQuery(name = "MateriaPrima.findByCodigo", query = "SELECT m FROM MateriaPrima m WHERE m.codigo = :codigo"),
    @NamedQuery(name = "MateriaPrima.findByNome", query = "SELECT m FROM MateriaPrima m WHERE m.nome = :nome"),
    @NamedQuery(name = "MateriaPrima.findByPreco", query = "SELECT m FROM MateriaPrima m WHERE m.preco = :preco")})
public class MateriaPrima implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    /** Atributo usado como chave primária pelo BD*/
    private Integer id;
    @Basic(optional = false)
    @Column(name = "CODIGO")
    private int codigo;
    @Basic(optional = false)
    @Column(name = "NOME")
    private String nome;
    @Basic(optional = false)
    @Column(name = "PRECO")
    private double preco;

    public MateriaPrima() {
    }

    public MateriaPrima(Integer id) {
        this.id = id;
    }

    public MateriaPrima(Integer id, int codigo, String nome, double preco) {
        this.id = id;
        this.codigo = codigo;
        this.nome = nome;
        this.preco = preco;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getCodigo() {
        return codigo;
    }

    public void setCodigo(int codigo) {
        this.codigo = codigo;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public double getPreco() {
        return preco;
    }

    public void setPreco(double preco) {
        this.preco = preco;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MateriaPrima)) {
            return false;
        }
        MateriaPrima other = (MateriaPrima) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dominio.MateriaPrima[id=" + id + "]";
    }

}
